package com.brokendust.client.config.module.image;

import com.brokendust.client.api.util.image.ImageControl;
import com.brokendust.client.config.module.ComponentJson;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class ImageShowJson implements ComponentJson {
    public String type;
    private String object_name;
    private String image;
    private int width;
    private int height;
    private int position;
    private int x;
    private int y;

    public ImageShowJson() {
        this.type = "Image";
        this.object_name = "";
        this.image = "";
    }

    public static ImageShowJson readJSON(String string) {
        GsonBuilder builder = new GsonBuilder();
        Gson gson = builder.create();
        return gson.fromJson(string, ImageShowJson.class);
    }

    public void refreshSize() {
        if (this.width == 0) {
            this.width = ImageControl.getWidth(this.image);
        }
        if (this.height == 0) {
            this.height = ImageControl.getHeight(this.image);
        }
    }

    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getImage() {
        return this.image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public int getWidth() {
        return this.width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return this.height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getPosition() {
        return this.position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public int getX() {
        return this.x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return this.y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public String getObject_name() {
        return this.object_name;
    }

    public void setObject_name(String object_name) {
        this.object_name = object_name;
    }
}

